package cn.lingyangwl.agile.pay.mch.controller;

import cn.lingyangwl.framework.core.response.Resp;
import cn.lingyangwl.agile.pay.model.rqrs.PayOrderQL;
import cn.lingyangwl.agile.pay.model.rqrs.pay.payorder.PayOrderRS;
import cn.lingyangwl.agile.pay.common.service.PayOrderService;
import cn.lingyangwl.agile.ram.ActionType;
import cn.lingyangwl.agile.ram.RamResource;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author shenguangyang
 */
@RestController
@RequestMapping("/pay/order")
public class PayOrderController {

    @Resource
    private PayOrderService payOrderService;

    /**
     * 分页 产品订单
     */
    @GetMapping("/pageOrder")
    @RamResource(action = "pay:payOrder:list", name = "查询支付订单列表", type = ActionType.READ)
    public Resp<IPage<PayOrderRS>> pageOrder(@Validated PayOrderQL req) {
        return Resp.ok(payOrderService.pagePayOrder(req));
    }

    /**
     * 通过id查找 产品订单
     */
    @GetMapping("/getById")
    @RamResource(action = "pay:payOrder:get", name = "查询支付订单详情", type = ActionType.READ)
    public Resp<PayOrderRS> getById(@RequestParam(value = "id") Long id) {
        return Resp.ok(payOrderService.getPayOrderById(id));
    }
}
